package com.hzy.fivepalace.service.controller.callback;


import com.hzy.fivepalace.db.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 支付回调控制层
 */
@RestController
@RequestMapping("/payCallback")
@Validated
public class PayCallbackController{

    @Resource
    private PayService payService;


    /**
     * 微信支付回调接口
     *
     * @param request
     * @param response
     * @return
     */
    @PostMapping("/weChat")
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
    public Object payNotify(HttpServletRequest request, HttpServletResponse response) {
        return payService.payCallbackWx(request, response);
    }


}
